package com.fei.android.flutternative2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends AppCompatActivity {

    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        context = this;

        Button btn_to_flutter = findViewById(R.id.btn_to_flutter_default);
        btn_to_flutter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(
                        FlutterActivity.createDefaultIntent(MainActivity.this)
                );

            }
        });

        Button btn_to_flutter_my_route = findViewById(R.id.btn_to_flutter_my_route);
        btn_to_flutter_my_route.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(
                        FlutterActivity
                                .withNewEngine()
                                .initialRoute("/my_route")
                                .build(MainActivity.this)
                );

            }
        });

        Button btn_to_flutter_my_route_2 = findViewById(R.id.btn_to_flutter_my_route_2);
        btn_to_flutter_my_route_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(
                        FlutterActivity
                                .withNewEngine()
                                .initialRoute("/my_route_2")
                                .build(MainActivity.this)
                );

            }
        });
    }
}